<template>
  <div id="ranking">
    <!-- 这是排行榜页面 -->
    <van-tabs v-model:active="active" type="card">
      <!-- 这是表头的vant组件 -->
      <van-tab title="热门榜"></van-tab>
      <van-tab title="预约榜"></van-tab>
      <van-tab title="热卖榜"></van-tab>
      <van-tab title="云玩榜"></van-tab>
    </van-tabs>
    <!-- 这是渲染的列表页面 -->
    <div class="liebiao">
      <div v-for="item of tabgamesList.arr" :key="item.id">
        <router-link :to="'/details/' + item.id">
          <div class="hang">
            <div class="zuo">
              <img :src="item.url" alt="" />
              <div class="neirong">
                <div class="mingzi">{{ item.title }}</div>
                <div class="fen">
                  <img src="@/assets/images/xing.png" alt="" />
                  <span> &nbsp;{{ item.score }} </span>
                  <span class="lei">{{ item.small.join(" · ") }}</span>
                </div>
              </div>
            </div>
            <div class="you">下载</div>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>
<script>
import { reactive, onMounted, ref } from "vue";
export default {
  setup() {
    const active = ref(0);
    //渲染列表的方法
    let tabgamesList = reactive({ arr: [] });
    const shuju = () => {
      fetch("http://8.142.22.78:3000/api/home/top")
        .then((response) => response.json())
        .then((res) => {
          if (res.status == 0) {
            tabgamesList.arr = res.result;
          }
        });
    };
    onMounted(() => {
      shuju();
    });
    return {
      shuju,
      tabgamesList,
      active,
    };
  },
};
</script>

<style lang="less" scoped>
#ranking {
  margin-bottom: 70px;
}
/deep/ .van-tabs__nav--card {
  border: none;
}
/deep/ .van-tabs__wrap {
  margin-bottom: 10px;
  width: 100%;
}
/deep/ .van-tabs {
  position: fixed;
  top: 60px;
  z-index: -1;
  height: 52px;
  .van-tab {
    width: 80px;
    height: 38px;
    border-radius: 5px;
    border: 1px solid #f5f5f5;
    background: #f5f5f5;
    text-align: center;
    line-height: 38px;
    color: gray;
    margin-right: 7px;
  }
  .van-tab--active span {
    background: #34c3c6;
    text-align: center;
    line-height: 38px;
    width: 86px;
    height: 38px;
    color: white;
    font-size: 18px;
    border-radius: 5px;
  }
}

.liebiao {
  position: fixed;
  left: 0;
  right: 0;
  top: 100px;
  bottom: 57px;
  z-index: -1;
  overflow: auto;
  padding-left: 20px;
  padding-right: 20px;
  .hang {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    .zuo {
      img {
        width: 67px;
        height: 67px;
        float: left;
      }
      .neirong {
        float: left;
        margin-left: 10px;
        margin-top: 10px;
        .mingzi {
          font-size: 16px;
          font-weight: 600;
          font-family: "楷体";
          color: #333333;
          margin-bottom: 3px;
        }
        .fen {
          font-size: 12px;
          color: #34c3c6;
          margin-top: 10px;
          img {
            width: 12px;
            height: 12px;
          }
        }
        .lei {
          font-size: 12px;
          margin-left: 5px;
          color: gray;
        }
      }
    }
    .you {
      width: 72px;
      height: 29px;
      border-radius: 15px;
      color: #34c3c6;
      background-color: #e6f8f8;
      font-size: 14px;
      text-align: center;
      line-height: 29px;
    }
  }
}
</style>
